/*
 * Tezad - Classic puzzle game
 * Copyright 2009 Shayne Riley and Paul Maseberg
 *
 * Tezad is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tezad is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tezad.  If not, see <http://www.gnu.org/licenses/>
 * or write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * To contact the authors on questions or issues regarding the license,
 * you may send an email to <pezads at gmail dot com>
 */

#include "GameMinoState.h"

GameMinoState::GameMinoState(int inRow, int inCol, int inOrientation)
: mRow(inRow), mCol(inCol),
mOrientation
(
        (inOrientation >= 0) ? (inOrientation % 4) : ((inOrientation * -1) % 4)
)
{ /* Empty */ }

GameMinoState::~GameMinoState()
{ /* Empty */ }

int GameMinoState::col() const
{
    return mCol;
}

int GameMinoState::row() const
{
    return mRow;
}

int GameMinoState::orientation() const
{
    return mOrientation;
}

GameMinoState GameMinoState::rotateCCW() const
{
    return GameMinoState(mRow, mCol, mOrientation + 3); // Yes, 3 is on purpose.
}

GameMinoState GameMinoState::rotateCW() const
{
    return GameMinoState(mRow, mCol, mOrientation + 1);
}

GameMinoState GameMinoState::shiftLeft() const
{
    return GameMinoState(mRow, mCol - 1, mOrientation);
}

GameMinoState GameMinoState::shiftRight() const
{
    return GameMinoState(mRow, mCol + 1, mOrientation);
}

GameMinoState GameMinoState::shiftUp() const
{
    return GameMinoState(mRow + 1, mCol, mOrientation);
}

GameMinoState GameMinoState::shiftDown() const
{
    return GameMinoState(mRow - 1, mCol, mOrientation);
}
